package net.j4love.json.jackson.example.quickstart;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import java.util.HashMap;
import java.util.Map;

/**
 * @author He Peng
 * @create 2017-05-21 15:08
 * @update 2017-05-21 15:08
 * @updatedesc : 更新说明
 * @see
 */
public class JacksonSerialize {

    public static void main(String[] args) throws JsonProcessingException {

        Map<String,Object> map = new HashMap<>();
        map.put("name","小明");
        map.put("性别","男");
        map.put("年龄",12);
        map.put("爱好","出现在各类九年制义务教育教材中");
        map.put("格言","我也很无奈啊");

        ObjectMapper objmpr = new ObjectMapper();

        // 是否对字符串进行格式化
        objmpr.configure(SerializationFeature.INDENT_OUTPUT,true);
        String text = objmpr.writeValueAsString(map);
        System.out.println(text);

    }

}
